<?php

namespace app\api\controller;

use app\common\controller\Api;
use think\Db;

/**
 * 系统设置接口
 */
class System extends Api
{
    protected $noNeedLogin = '*';
    protected $noNeedRight = '*';

    /**
    * 获取版本信息
    */
    public function version(){

        $ver = Db::name('verlist')->order("id desc")->find();
        if(!$ver) {
            $this->error('获取数据失败');
        }
        $this->success('获取成功', $ver);
    }

    /**
    * 初始化项目
    */
    public function restart(){
        $gcbh  = $this->request->request("gcbh");
        $status  = $this->request->request("status");//初始 1创建，2采集，3编辑采集，4进场安排
        if (!$gcbh || !$status) {
            $this->error(__('Invalid parameters'));
        }
        if ($status <4) {
            //删除工程信息，
            Db::table('zuoyedata')->where('Gcbh',$gcbh)->delete();
            Db::table('projectdata')->where('Gcbh',$gcbh)->delete();
            //采集信息
            Db::table('zuoyesubdata')->where('Gcbh',$gcbh)->delete();
            Db::table('startorfinishdata')->where('Gcbh',$gcbh)->delete();
            Db::table('apptempdata')->where('gcbh',$gcbh)->delete();
            Db::table('linedata')->where('gcbh',$gcbh)->delete();
            Db::table('loaclworkordangerousdata')->where('Gcbh',$gcbh)->delete();
            
        }
        if($status<5) {
            //删除进场安排信息
            Db::table('gc_pda_worker')->where('gcbh',$gcbh)->delete();
        }

        $this->success('初始化成功');
    }
    
   
}